package com.itcam.cm.manager.controller;


import com.itcam.cm.manager.service.SysRoleMenuService;
import com.itcam.cm.manager.service.SysRoleService;
import com.itcam.cm.model.dto.system.AssginMenuDto;
import com.itcam.cm.model.dto.system.SysRoleDto;
import com.itcam.cm.model.entity.system.SysRole;
import com.itcam.cm.model.vo.common.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin(allowCredentials = "true" , originPatterns = "*" , allowedHeaders = "*")
@RequestMapping("/admin/system/sysRoleMenu")
public class SysRoleMenuController {

    @Autowired
    SysRoleMenuService sysRoleMenuService;

    @GetMapping("findSysRoleMenuByRoleId/{roleId}")
    public Result<Map<String,Object>> findSysRoleMenuByRoleId(@PathVariable Long roleId){
        // 调用业务层传入参数查询分页
        Map<String,Object> map = sysRoleMenuService.findSysRoleMenuByRoleId(roleId);
        return Result.ok(map);
    }

    @PostMapping("doAssign")
    public Result doAssign(@RequestBody AssginMenuDto assginMenuDto){
        sysRoleMenuService.doAssign(assginMenuDto);
        return Result.ok(null);
    }


}
